package org.yinweichen.llm_dataset_backend.controller;

import lombok.RequiredArgsConstructor;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import org.yinweichen.llm_dataset_backend.DTO.PointsCreateDTO;
import org.yinweichen.llm_dataset_backend.DTO.PointsKeywordUpdateDTO;
import org.yinweichen.llm_dataset_backend.DTO.PointsUpdateDTO;
import org.yinweichen.llm_dataset_backend.entity.Points;
import org.yinweichen.llm_dataset_backend.service.PointsService;

import java.util.List;

@RestController
@RequestMapping("/api/points")
@RequiredArgsConstructor
public class PointController {
    private final PointsService pointsService;

    @GetMapping("/{questionId}/{version}")
    public ResponseEntity<List<Points>> getPointsByAnswerId(
            @PathVariable Long questionId,
            @PathVariable String version) {
        return pointsService.getPointsByAnswerId(questionId, version);
    }

    @PostMapping
    public ResponseEntity<Points> createPoint(@RequestBody PointsCreateDTO pointsCreateDTO) {
        return pointsService.createPoint(pointsCreateDTO);
    }

    @PutMapping("/inactivate/{questionId}/{version}/{pointId}")
    public ResponseEntity<Void> inactivatePoint(
            @PathVariable Long questionId,
            @PathVariable String version,
            @PathVariable Long pointId) {
        return pointsService.inactivatePoint(questionId, version, pointId);
    }

    @PutMapping("/activate/{questionId}/{version}/{pointId}")
    public ResponseEntity<Void> activatePoint(
            @PathVariable Long questionId,
            @PathVariable String version,
            @PathVariable Long pointId) {
        return pointsService.activatePoint(questionId, version, pointId);
    }

    @PutMapping("/update/value")
    public ResponseEntity<Points> updateValue(@RequestBody PointsUpdateDTO pointsUpdateDTO) {
        return pointsService.updateValue(pointsUpdateDTO);
    }

    @PutMapping("/update/keyword")
    public ResponseEntity<Points> updateKeyword(@RequestBody PointsKeywordUpdateDTO pointsKeywordUpdateDTO) {
        return pointsService.updateKeyword(pointsKeywordUpdateDTO);
    }
}
